package app.mybean;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import app.mybean.Exam;
import app.mybean.Manager;




public class AddExamServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public AddExamServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
		String courseid,coursename,daytime,template,tea_id,i_id;
		response.setContentType("text/html");
		courseid=request.getParameter("courseid");
		coursename=request.getParameter("coursename");
		daytime=request.getParameter("daytime");
		template=request.getParameter("template");
		tea_id=request.getParameter("tea_id");
		i_id=(String)request.getSession().getAttribute("i_id");
		Exam add=Manager.getInstance().AddExamInfo(courseid, coursename, daytime, template,tea_id,i_id);
		//System.out.println("Success!");
		request.getSession().setAttribute("examinfo", add);
		response.sendRedirect(request.getContextPath() + "/tea_po.jsp");
	}


	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
